-
A JS worker that runs between the browser and network.
-
Can intercept requests, serve cached responses, enable offline pages, and run background tasks (push, sync).
-
Requires HTTPS (or localhost for dev).
-
Adds complexity and subtle bugs. Caching logic is error-prone and easily serves stale pages to visitors.
-
You must design update semantics (skipWaiting, cache versioning) or users will see old assets.
-
Debugging and lifecycle issues consume time.
-
Not needed if you do not need offline access or push notifications.
-
SW could be useful if:
-
You want offline reading for notes.
-
You want to present a snappy cached shell for repeat visitors.
-
You plan to add a PWA experience or push notifications.
-
Service Workers (SW)